﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ETL.Business.Handlers.ProjectUserHandler;
using ETL.Entity;

namespace ETL.Business.Models
{
    public class ProjectModel
    {
        public PROJECT Project { get; set; }

        public ProjectModel(PROJECT project)
        {
            this.Project = project;
        }

        /// <summary>
        /// Project Id : pr_ref
        /// </summary>
        public decimal ProjectId { get { return Convert.ToInt32(Project.PROJECT_ID); } }

        /// <summary>
        /// Project created by
        /// </summary>
        //public string ProjectCreatedBy { get { return Project.pr_created_by; } }

        /// <summary>
        /// Project name
        /// </summary>
        public string ProjectName { get { return Project.PROJECT_NAME; } }

        public string ProjectLeadEngineer
        {
            get
            {
                var user = (new GetUserById().Execute(Project.LEAD_ENGINEER_EMP_ID));
                if(user != null)
                {
                    return user.FirstName + " " + user.SurName;
                }
                return string.Empty;
            }
        }
        /// <summary>
        /// Project description
        /// </summary>
        //public string ProjectDescription { get { return Project.pr_description; } }

        /// <summary>
        /// Project status
        /// </summary>
        public string ProjectStatus { get { return Project.STATUS; } }

        /// <summary>
        /// Project Lead engineer
        /// </summary>
        //public string ProjectLeadEnginner { get { return Project.pr_lead_eng; } }

        /// <summary>
        /// project start date
        /// </summary>
        public DateTime? ProjectStartDate { get { return Project.SCHEDULED_START_DATE; } }

        /// <summary>
        /// Get or set project end date
        /// </summary>
        public DateTime? ProjectEndDate { get { return Project.SCHEDULED_END_DATE; } }

        /// <summary>
        /// Get or set project completed status
        /// </summary>
        //public bool? ProjectCompleted { get { return Project.pr_complete_flag; } }

        /// <summary>
        /// Get or set project suspended status
        /// </summary>
        //public bool? ProjectSuspended { get { return Project.pr_suspended; } }

        /// <summary>
        /// Get the displayed name that will represent in dropdownlist project
        /// </summary>
        public string DisplayedName
        {
            get
            {
                var result = this.ProjectName; // + "  " + this.ProjectDescription;
                //if(this.ProjectSuspended == true)
                //{
                //    result += "  (Suspended)";
                //}
                return result;
            }
        }

        /// <summary>
        /// Get the selected value that will displayed in dropdownlist project
        /// </summary>
        public string Selected { get; set; }

    }
}
